<template>
  <div class="ma-content-block lg:flex justify-between p-4">
    <!-- CRUD 组件 -->
    <ma-crud :options="options" :columns="columns" ref="crudRef">
    </ma-crud>
  </div>
</template>
<script setup>
import { ref, reactive } from 'vue'
import systemDeviceNav from '@/api/system/systemDeviceNav'
import { Message } from '@arco-design/web-vue'
import tool from '@/utils/tool'
import * as common from '@/utils/common'

const crudRef = ref()

const props = defineProps(["client", "curDevieInfo", "case_id","isDelete"]);

console.log(props.curDevieInfo)
console.log(props.client)
const numberOperation = (newValue, id, numberName) => {
  systemDeviceNav.numberOperation({ id, numberName, numberValue: newValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}

const switchStatus = (statusValue, id, statusName) => {
  systemDeviceNav.changeStatus({ id, statusName, statusValue }).then( res => {
    res.success && Message.success(res.message)
  }).catch( e => { console.log(e) } )
}


const options = reactive({
  beforeRequest: params => {
    // 指定排序字段为浏览量字段
    params.device_num = props.curDevieInfo.device_num

    params.case_id = props.case_id ? props.case_id : 0

  },

  id: 'system_device_nav',
  rowSelection: {
    showCheckedAll: true
  },
  pk: 'id',
  operationColumn: true,
  operationWidth: 160,
  formOption: {
    viewType: 'modal',
    width: 600
  },
  api: systemDeviceNav.getList,
  recycleApi: systemDeviceNav.getRecycleList,
  add: {
    show: false,
    api: systemDeviceNav.save,
    auth: ['system:deviceNav:save']
  },
  edit: {
    show: false,
    api: systemDeviceNav.update,
    auth: ['system:deviceNav:update']
  },
  delete: {
    show: true,
    api: systemDeviceNav.deletes,
    auth: ['system:deviceNav:delete'],
    realApi: systemDeviceNav.realDeletes,
    realAuth: ['system:deviceNav:realDeletes']
  },
  recovery: {
    show: true,
    api: systemDeviceNav.recoverys,
    auth: ['system:deviceNav:recovery']
  },
  import: {
    show: true,
    url: 'system/deviceNav/import',
    templateUrl: 'system/deviceNav/downloadTemplate',
    auth: ['system:deviceNav:import']
  },
  export: {
    show: true,
    url: 'system/deviceNav/export',
    auth: ['system:deviceNav:export']
  }
})

const columns = reactive([
  {
    title: "",
    dataIndex: "id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    commonRules: {
      required: true,
      message: "请输入"
    }
  },
  {
    title: "设备编码",
    dataIndex: "device_num",
    formType: "input",
    search: true
  },
  {
    title: "巡逻方案",
    dataIndex: "case_id",
    formType: "input",
    search: false
  },
  {
    title: "导航阶段",
    dataIndex: "res",
    formType: "input",
    search: true
  },
  {
    title: "阶段结果",
    dataIndex: "reason",
    formType: "input"
  },
  {
    title: "导航名称",
    dataIndex: "goal",
    formType: "input",
    search: true
  },
  {
    title: "离目标点距离",
    dataIndex: "dist",
    formType: "input"
  },
  {
    title: "所属点位",
    dataIndex: "point_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "创建时间",
    dataIndex: "created_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "更新时间",
    dataIndex: "updated_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "删除时间",
    dataIndex: "deleted_at",
    formType: "date",
    addDisplay: false,
    editDisplay: false,
    hide: true,
    showTime: true
  },
  {
    title: "创建者",
    dataIndex: "created_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "更新者",
    dataIndex: "updated_by",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },
  {
    title: "所属区域",
    dataIndex: "dept_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  },

  {
    title: "地图名",
    dataIndex: "map_name",
    formType: "input",
    search: false,
    hide: true
  },
  {
    title: "里程数",
    dataIndex: "melieage",
    formType: "input",
    search: false,
    hide: true
  },
  {
    title: "消息ID",
    dataIndex: "message_id",
    formType: "input",
    addDisplay: false,
    editDisplay: false,
    hide: true
  }
])
</script>
<script> export default { name: 'system:deviceNav' } </script>